<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        function timer(t) {
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve('data-' + t)
                }, t);
            })
        }

        async function *gen(){
            yield timer(1000);
            yield timer(1000);
            yield timer(1000);
        }

        async function test() {
            let g = gen();
            let arr = [g.next(),g.next(),g.next()];

            for await (let item of arr) {
                console.log(item);
            }
        }
        test();
    </script>
</body>

</html>